<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('api手动推送记录列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>

                            <li>
                                <label>机构信息：</label>
                                <select name="dataId" class="form-control" >
                                    <option value="">所有</option>
                                    <option  th:each="item:${channelInfoList}" th:text="${item.name}" th:value="${item.value}"></option>
                                </select>
                            </li>
                            <li>
                                <label>任务状态：</label>
                                <select name="status" class="form-control" >
                                    <option value="">所有</option>
                                    <option value="0">待执行</option>
                                    <option value="1">正在执行</option>
                                    <option value="2">执行结束</option>
                                </select>
                            </li>
                            <li>
                                <label>执行日期：</label>
                                <input type="text" name="execDate" id="execDate" autocomplete="off"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-success" onclick="pushData();" >-->
<!--                    <i class="fa fa-plus"></i> 手动推送-->
<!--                </a>-->
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="form:record:add">
                    <i class="fa fa-plus"></i> 添加推送任务
                </a>
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="form:record:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="form:record:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="form:record:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('form:record:edit')}]];
        var removeFlag = [[${@permission.hasPermi('form:record:remove')}]];
        var prefix = ctx + "form/record";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "推送任务",
                columns: [
                //     {
                //     checkbox: true
                // },
                {
                    field: 'id',
                    title: '任务ID'
                },
                // {
                //     field: 'dataId',
                //     title: ''
                // },
                {
                    field: 'dataName',
                    title: '机构名称',
                    formatter: function (value, row, index) {
                        return row.dataName + '['+row.dataId+']';
                    }
                },
                // {
                //     field: 'actionType',
                //     title: '操作类型'
                // },
                // {
                //     field: 'infoType',
                //     title: ''
                // },
                    {
                        field: 'starttime',
                        title: '执行信息',
                        formatter: function (value, row, index) {
                            return  '执行日期：'+row.execDate +'<br> ' +
                                '开始时间：'+row.execStartTime +'<br> ' +
                                '结束时间：'+row.execEndTime;
                        }
                    },

                    {
                        field: 'starttime',
                        title: '数据范围时间',
                        formatter: function (value, row, index) {
                            return  '开始时间：'+row.starttime +'<br> ' +
                                '结束时间：'+row.endtime;
                        }
                    },
                    {
                        field: 'pushSpace',
                        title: '推送时间间隔'
                    },
                    {
                        field: 'statusStr',
                        title: '状态',
                    },
                {
                    field: 'starttime',
                    title: '运行信息',
                    formatter: function (value, row, index) {

                        var html = '';
                        if (row.runStartTime != undefined){
                            html += '开始时间：'+row.runStartTime +'<br> ';
                        }
                        if (row.runEndTime != undefined){
                            html += '结束时间：'+row.runEndTime +'<br> ';
                        }
                        return html;
                    }
                },
                // {
                //     field: 'endtime',
                //     title: '手动结束时间'
                // },

                // {
                //     field: 'realStarttime',
                //     title: '实际开始时间'
                // },
                // {
                //     field: 'realEndtime',
                //     title: '实际结束时间'
                // },
                {
                    field: 'totalNumber',
                    title: '推送信息',
                    formatter: function (value, row, index) {
                        return  '总：'+row.totalNumber +'<br> ' +
                            '成功：'+row.successNumber+'<br> ' +
                            '失败：'+row.failedNumber;
                    }
                },
                // {
                //     field: 'totalNumber',
                //     title: ''
                // },
                // {
                //     field: 'successNumber',
                //     title: ''
                // },
                // {
                //     field: 'failedNumber',
                //     title: ''
                // },

                {
                    field: 'descInfo',
                    title: '备注'
                },
                // {
                //     field: 'operatorId',
                //     title: '操作员'
                // },
                // {
                //     field: 'operatorName',
                //     title: '操作员'
                // },
                {
                    field: 'createTime',
                    title: '任务信息',
                    formatter: function (value, row, index) {
                        var html = '';
                        if (row.operatorName != undefined){
                            html += '操作员：'+row.operatorName +'<br> ';
                        }
                        if (row.createTime != undefined){
                            html += '创建时间：'+row.createTime +'<br> ';
                        }
                        if (row.updateTime != undefined){
                            html += '更新时间：'+row.updateTime +'<br> ';
                        }
                        return html;
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }
                ]
            };
            $.table.init(options);
        });

        /*字典列表-详细*/
        function pushData() {
            var url = prefix + '/pushData/';
            $.modal.open("手动推送", url
            //     , 800, 800, function (value) {
            //     console.log("数据刷新")
            //     $.table.refresh("bootstrap-table")
            // }
            );
        }

        layui.use('laydate', function(){
            var laydate = layui.laydate;
            laydate.render({
                elem: '#execDate',
                type: 'date'
            });
        });
    </script>
</body>
</html>